<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%String path = request.getContextPath() ;%>
<%@ taglib uri="/WEB-INF/tld/c.tld" prefix="c" %> 
<%@ taglib uri="/WEB-INF/tld/ui.tld" prefix="ui" %> 
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>旧车报告展示列表页面</title>
<jsp:include page="../../import.jsp" flush="true" />
</head>
<body class="iframeBody">
<div class="Wrapper">
	<div class="searchArea">
	    <!-- 查询表单 -->
	    <form id="searchBar">
	        <div class="fieldset1 clearFix">
				<div class="fieldBox">
					<div class="label">车架号</div>
					<div class="field">
						<input type="text" id="vin" name="vin" class="ui-textbox" ligerui="width: 160" value="">
						<!-- 功能按钮 -->
						<span id="searchBtn" class="sq-button sq-button-hasicon"><i class="sqBtnIco_1"></i>查询</span>
               			<span id="clearBtn" class="sq-button sq-button-hasicon"><i class="sqBtnIco_19"></i>清空</span>
	               		<input id="resetBtn" type="reset" value="重置" class="l-button l-button-reset Hide"/>
					</div>
				</div>
	        </div>
	    </form>
	</div>
    <!-- 列表显示块 -->
	<div id="ligergrid1" class="sq-grid"></div>
</div>

<script type="text/javascript">
	var grid = null;
	$(function () {
		initForm();//初始化表单
		initGrid();//注意初始化要在initForm之后,因为在初始化grid的时候需要form参数
	    searchBtnEvent();//查询按钮事件
	    clearBtnEvent();//清空按钮事件
	});
	
	//初始化表单
	function initForm(){
		$("#searchBar").ligerForm();
	}
	
	//查询参数
	function getSearchParams(){
		var form = new liger.get("searchBar");
		var data = form.getData();
		return data;
	}
	
	//初始化列表
	function initGrid(){
		$("#ligergrid1").ligerGrid({
			url:'<%=path%>/car300/infCar300Rec/initList.do',
			method:'get',
			parms:getSearchParams(),
			columns:[
				{ display: '车架号', name: 'vin', width: 150 , align:'center', enabledSort:true,
					render: function (rowdata, rowindex, value, column) { 
						var h = '';
						h='<a href="javascript:showReport(';
	                    h+="'"+rowdata.id+"',"; //主键
	                    h+="'"+rowdata.vin+"'"; //车架号
						h+=')">'+value+'</a>';
						return h;
					}},
				{ display: '品牌', name: 'brandName', width: 100 , align:'center', enabledSort:true},
				{ display: '车系', name: 'seriesName', width: 100 , enabledSort:true},
				{ display: '车型', name: 'modelName', minWidth: 150 , enabledSort:true,
	                render: function (item) {
	                	var h = '<span class="gridTip" style="cursor: pointer;" title="' + item.modelName + '">' + item.modelName + '</span>';
	                	return h;
	                }},
				{ display: '所在城市', name: 'cityName', width: 100, align:'center', enabledSort:true},
				{ display: '初次上牌年月', name: 'regDate', minWidth: 100, align:'center', enabledSort:true},
				{ display: '表显里程(万公里)', name: 'shownMile', minWidth: 120, align:'center', enabledSort:true},
				{ display: '评估里程(万公里)', name: 'evalMile', width: 120, align:'center', enabledSort:true},
				{ display: '过户次数', name: 'transferTimes', minWidth: 80, align:'center', enabledSort:true},
				{ display: '排量(升)', name: 'liter', minWidth: 80, align:'center', enabledSort:true},
				{ display: '出厂年月', name: 'makeDate', minWidth: 100, align:'center', enabledSort:true},
				{ display: '发动机号', name: 'engineNo', minWidth: 100, align:'center', enabledSort:true},
				{ display: '车身颜色', name: 'color', minWidth: 100, align:'center', enabledSort:true},
				{ display: '报告生成时间', name: 'reportTime', minWidth: 150, align:'center', enabledSort:true}
			],
			pageSize:10,
			root:'rows',
			record:'total',
			hideLoadButton:false,
			width:'100%',
			height:'100%',
			heightDiff:-2,
			checkbox:false,//列表是否有选择框
			rownumbers:true//列表是否有行号
		});
		grid = liger.get("ligergrid1");
		grid.setHeight(100);
		grid.options.isSingleCheck = true;//列表是否为单选
	}
	
	//查看报告详情
	function showReport(id, vin){
		var url = '<%=path%>/car300/infCar300Rec/toReportViewPage.do?';
		Add_navTab('tab_report_'+id,'旧车评估报告',url+'id='+id+'&vin='+vin);
	};
	
	//查询按钮事件
	function searchBtnEvent(){
		$("#searchBtn").click(function(event) {
			var form = new liger.get("searchBar");
			var data = form.getData();
			for (name in data){
				grid.setParm(name,data[name]);
			};
			grid.reload();
		});
	}
	
	//清空按钮事件
	function clearBtnEvent(){
		$("#clearBtn").click(function(event) {
	        $("#resetBtn").click();  //重置 input-text
	    });
	}
</script>
</body>
</html>